package priv.yiyuan.example.design.chain;

/**
 * 新用户折扣
 *
 * @author YiYuan
 * @data 2025/10/11
 * @apoNote
 */
public class NewUserDiscountStrategy implements DiscountStrategy {

    @Override
    public double calculateDiscount(Order order) {

        if (order.isNewUser()) {
            double discountAmount = order.getOriginalPrice() * 0.1;
            order.addAppliedDiscountInfo("新用户折扣(10%)");
            System.out.println("应用新用户折扣: 优惠 " + String.format("%.2f", discountAmount) + "元。");
            return discountAmount;
        }

        return 0;
    }
}
